package com.milling.business.service.impl;

import java.util.List;
import java.util.Map;

import com.milling.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.milling.business.mapper.WmsCellInfoMapper;
import com.milling.business.domain.WmsCellInfo;
import com.milling.business.service.IWmsCellInfoService;

/**
 * 货位设置Service业务层处理
 *
 * 共22层，每层28列
 * 第22行 和 28列设为故障
 * update wms_cell_info set cell_status = '5' where s_column=28
 * update wms_cell_info set cell_status = '5' where s_row=22
 *
 *  * 16  17 行空缺        5  6  7         16  17  18
 *  *
 *  * 双面共 1208          单面 604           去除22行和28列(98个库位)；   剩余1208 - 98 = 1110
 *
 * @author X
 * @date 2025-02-06
 */
@Service
public class WmsCellInfoServiceImpl implements IWmsCellInfoService
{
    @Autowired
    private WmsCellInfoMapper wmsCellInfoMapper;

    /**
     * 查询货位设置
     *
     * @param cellId 货位设置主键
     * @return 货位设置
     */
    @Override
    public WmsCellInfo selectWmsCellInfoByCellId(Long cellId)
    {
        return wmsCellInfoMapper.selectWmsCellInfoByCellId(cellId);
    }

    /**
     * 查询货位设置列表
     *
     * @param wmsCellInfo 货位设置
     * @return 货位设置
     */
    @Override
    public List<WmsCellInfo> selectWmsCellInfoList(WmsCellInfo wmsCellInfo)
    {
        return wmsCellInfoMapper.selectWmsCellInfoList(wmsCellInfo);
    }

    /**
     * 新增货位设置
     *
     * @param wmsCellInfo 货位设置
     * @return 结果
     */
    @Override
    public int insertWmsCellInfo(WmsCellInfo wmsCellInfo)
    {
        wmsCellInfo.setCreateTime(DateUtils.getNowDate());
        return wmsCellInfoMapper.insertWmsCellInfo(wmsCellInfo);
    }

    /**
     * 修改货位设置
     *
     * @param wmsCellInfo 货位设置
     * @return 结果
     */
    @Override
    public int updateWmsCellInfo(WmsCellInfo wmsCellInfo)
    {
        wmsCellInfo.setUpdateTime(DateUtils.getNowDate());
        return wmsCellInfoMapper.updateWmsCellInfo(wmsCellInfo);
    }

    /**
     * 批量删除货位设置
     *
     * @param cellIds 需要删除的货位设置主键
     * @return 结果
     */
    @Override
    public int deleteWmsCellInfoByCellIds(Long[] cellIds)
    {
        return wmsCellInfoMapper.deleteWmsCellInfoByCellIds(cellIds);
    }

    /**
     * 删除货位设置信息
     *
     * @param cellId 货位设置主键
     * @return 结果
     */
    @Override
    public int deleteWmsCellInfoByCellId(Long cellId)
    {
        return wmsCellInfoMapper.deleteWmsCellInfoByCellId(cellId);
    }

    public List<Map> selectCellStock(WmsCellInfo wmsCellInfo) {
        return wmsCellInfoMapper.selectCellStock(wmsCellInfo);
    }

}
